<template>
  <div>
    <div v-if="fd">
      <div class="box"></div>
      <div v-for="(item, index) in fd.list" :key="index" @click="fd.again(index)">
        {{ item.url }}
      </div>
      <Row>
        <Button type="default" @click="add">操作</Button>
      </Row>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
import FetchDebug from './251118_1.js'
export default {
  name: '251118',
  data() {
    return {
      a: 1,
      b: 2,
      /**
       * @type {FetchDebug}
       */
      fd: null
    }
  },
  methods: {
    add() {
      this.instance
        .get('1.php', {
          params: {
            a: 1,
            b: 2
          },
          data: {
            a: 1,
            b: 2
          }
        })
        .catch((err) => {
          console.log(err)
        })
    }
  },
  mounted() {
    const instance = axios.create()
    instance.interceptors.request.use(
      (config) => {
        console.log(config)
        this.fd.save(config)
        return config
      },
      (err) => {
        //return Promise.reject(err)
      }
    )
    this.instance = instance
    this.fd = new FetchDebug(axios)
  },
  created() {
    console.log(`h2`)
  }
}
</script>

<style lang="scss" scoped>
.box {
  width: 100px;
  height: 100px;
  border: 1px solid #000;
}
</style>
